//package com.jxw.cloudpen.web.netty.websocketclient;
//
//import com.alibaba.fastjson.JSONObject;
//import com.google.api.gax.rpc.ResponseObserver;
//import com.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse;
//import com.jxw.cloudpen.web.netty.Entity.ChatGptRequest;
//import com.jxw.cloudpen.web.netty.Entity.ChatGptTxtRequest;
//import com.jxw.cloudpen.web.netty.Entity.StreamData;
//import org.java_websocket.client.WebSocketClient;
//import org.java_websocket.handshake.ServerHandshake;
//
//import javax.sound.sampled.*;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.nio.ByteBuffer;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.concurrent.BlockingQueue;
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//import java.util.concurrent.LinkedBlockingQueue;
//
//public class MyWebSocketClientV3 extends WebSocketClient {
//    ExecutorService pool = Executors.newFixedThreadPool(3);
//    public MyWebSocketClientV3(URI serverUri) {
//        super(serverUri);
//    }
//
//    @Override
//    public void onOpen(ServerHandshake handshakedata) {
//        System.out.println("Connected");
////        this.send("Hello Server!"); // 发送消息到服务器
////        for(;;){
////            this.send(ByteObjUtil.objToBytes("aaaa"));
////            this.send("aaaa");
////            try {
////                Thread.sleep(3000);
////            } catch (InterruptedException e) {
////                e.printStackTrace();
////            }
////        }
////        StreamData streamData = new StreamData();
////        streamData.setType(1);
////        streamData.setClientId("f544f5209e7d4f59a82ba3a780736faf");
////        this.send(ByteObjUtil.objToBytes(streamData));
//
//        ChatGptRequest request = new ChatGptRequest();
//        request.setClientId("f544f5209e7d4f59a82ba3a780736faf");
//        request.setToken("login_jxwdevice21382749hc2xa8ah7ab6h1cht0rb39mu7xcbi3dy");
//
//        List<ChatGptTxtRequest> txtRequestList = new ArrayList<>();
//        ChatGptTxtRequest txtRequest = new ChatGptTxtRequest();
//        txtRequest.setUserMessage("来一遍200字作文，讲的是爸爸");
//        txtRequestList.add(txtRequest);
////        request.setChatGptTxtRequestList(txtRequestList);
//        request.setChatGptTxtRequest(txtRequest);
////        this.send(ByteObjUtil.objToBytes(result));
//
//        System.out.println(JSONObject.toJSONString(request));
//        this.send(JSONObject.toJSONString(request));
//
//
//
//        pool.submit(() -> {
//            try {
//                Thread.sleep(6000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//
////            ChatGptRequest  request2 = new ChatGptRequest();
////            request2.setClientId("f544f5209e7d4f59a82ba3a780736faf");
////            request2.setChatGptTxtRequestList(txtRequestList);
////            request2.setIsStop(true);
////            this.send(JSONObject.toJSONString(request2));
//
//
////            try {
////                Thread.sleep(1000);
////            } catch (InterruptedException e) {
////                e.printStackTrace();
////            }
////
////            ChatGptRequest request3 = new ChatGptRequest();
////            request3.setClientId("f544f5209e7d4f59a82ba3a780736faf");
////            List<ChatGptTxtRequest> txtRequestList2 = new ArrayList<>();
////            ChatGptTxtRequest txtRequest2 = new ChatGptTxtRequest();
////            txtRequest2.setUserMessage("来一遍500字作文，讲的是爸爸");
////            txtRequestList2.add(txtRequest2);
////            request3.setChatGptTxtRequestList(txtRequestList2);
//////        this.send(ByteObjUtil.objToBytes(result));
////            this.send(JSONObject.toJSONString(request3));
//
//
//        });
//
//
//    }
//
//
//    private static TargetDataLine targetDataLine;
//
//    private static volatile BlockingQueue<byte[]> sharedQueue = new LinkedBlockingQueue<byte[]>();
//
//
//    @Override
//    public void onMessage(String message) {
//        System.out.println("Received: " + message);
//
//        JSONObject jsonObject =JSONObject.parseObject(message);
//        jsonObject.getString("clientId");
//
//
//    }
//
//    @Override
//    public void onMessage(ByteBuffer bytes) {
//        System.out.println("Received: " + bytes);
//    }
//
//    @Override
//    public void onClose(int code, String reason, boolean remote) {
//        System.out.println("Disconnected");
//    }
//
//    @Override
//    public void onError(Exception ex) {
//        System.err.println("Error: " + ex.getMessage());
//    }
//
//    public static void main(String[] args) throws URISyntaxException {
////        String url = "wss://gwsdb-sgp-test.xuexizhiwang.com/chatgpt";
//        String url = "ws://localhost:6601/chatgpt";
////        String url = "ws://172.19.192.8:31284/test";
//        MyWebSocketClientV3 client = new MyWebSocketClientV3(new URI(url)); // 替换为你的WebSocket服务器地址和端点
//        client.addHeader("Accept-Language","fr-CH");
//        client.connect();
//    }
//}
